﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="Mo,Asp,MoAspEnginer,Blog,MoBlog,艾恩" />
    <meta name="description" content="基于JScript和VBScript的ASP开源MVC框架-MoAspEnginer。" />
    <title>ExceptionManager控制台</title>
    <style type="text/css">
	    body {font-size:12px; font-family: "微软雅黑","microsoft yahei",Arial, "MS Trebuchet", sans-serif;}
	    #logs {border-radius:5px; padding: 10px; margin:10px;width:50%}
	    #logs div {margin:5px 0;border-bottom:1px dotted #eee; padding:10px;}
	    table {border-collapse:collapse;}
	    table tr th,table tr td {padding:3px;height:24px;line-height:24px;border-bottom:1px #999 solid; text-align: center;}
	    table tr td {border-bottom:1px #eee solid;}
	    table tr td.lastitem{border-top:1px #999 solid;}
	    table tr th {border-top:1px #999 solid;}
	    #panel {height:20px; line-height:20px;margin-bottom:10px}
	    input[type='text']{height:20px; line-height:20px;width:60px;padding:0 3px; border:1px #999 solid}
	    h2{padding:0;margin:0;height:48px; line-height:48px}
    </style>
	<script type="text/javascript">
	var box = null, 
		colors = {E_ERROR : 'red',E_NOTICE : 'orange',E_WARNING : 'blue',E_INFO : 'green',E_MODEL : "green"}, bgcolor = ["#fff","#fafafa"],color = 0,timer = 0,max = 50,
		getXMLHttpRequest=function(){var a=null;if(window.XMLHttpRequest){a=new XMLHttpRequest();getXMLHttpRequest=function(){return new XMLHttpRequest()}}else{if(window.ActiveXObject){var e=["MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp","MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0"];for(var d=e.length-1;d>=0;d--){try{getXMLHttpRequest=(function(b){return function(){return new ActiveXObject(b)}})(e[d]);a=getXMLHttpRequest()}catch(c){}}}}return a}, 
		Ajax = function(c,d,b){var a=getXMLHttpRequest();if(a==null){if(typeof b=="function"){b("XMLHttpRequest组件初始化失败")}return}d=d||function(){};b=b||function(){};a.open("GET",c,true);a.onreadystatechange=(function(e){return function(){if(e.readyState==4){if(e.status==200){try{d.call(e,(new Function("return "+e.responseText+";"))())}catch(ex){d.call(e,null)}}else{b.call(e,e.status,e.responseText)}}}})(a);a.send();a=null},
		format = function(b){var a=arguments;if(a.length<=1){return b}return b.replace(/\{(\d+)(\.([\w\.]+))?\}/igm,function(e){try{var d=/\{(\d+)(\.([\w\.]+))\}/igm.exec(e);if(d!=null){return(new Function("return this["+(parseInt(d[1])+1)+']["'+d[3].replace(/\./igm,'"]["').replace(/\[\"(\d+)\"\]/igm,"[$1]")+'"]')).call(a)}return a[parseInt(e.replace(/\{(\d+)\}/igm,"$1"))+1]}catch(c){return e}})};

	function start(){
		Ajax(
			"?m=Console&a=Show<nempty name='APP'>&app={$APP}</nempty>&_r=" + Math.random(),
			function(msg){
				var child = box.firstChild;
				if(msg){
					var len = msg.length;
					if(len>0){
						createheader(new Date(),child);
					}
					for(var i=0;i<len;i++){
						create(msg[i], child);
					}
					while(box.childNodes.length>max) box.removeChild(box.lastChild);
				}else{
					createheader(new Date(), child);
					createerror("DEBUG数据异常：" + this.responseText, child);
				}
				timer = window.setTimeout(start, 3000);
			},
			function(status, text){
				var child = box.firstChild;
				createheader(new Date(), child);
				createerror("服务器错误：" + status, child);
				timer = window.setTimeout(start, 3000);
			}
		);
	}
	function createheader(msg, last){
		var list = document.createElement("tr");
		list.innerHTML = "<td colspan=\"8\">"+msg+"</td>";
		list.style.cssText = "color:#999;background-color:#f3f3f3;";
		if(box.firstChild && last)box.insertBefore(list, last);
		else box.appendChild(list);
	}
	function create(msg, last){
		var list = document.createElement("tr");
		list.innerHTML = format("<td>{0.datetime}</td><td>0x{0.number}</td><td>{0.method}.{0.action}</td><td>{0.source}</td><td style=\"color:" + colors[msg.level] + ";text-align:left\">{0.message}</td><td>{0.level}</td><td>{0.filename}</td><td>{0.linenumber}</td>",msg);
		list.style.cssText = "color:#666;background-color:" + bgcolor[color];
		if(box.firstChild && last)box.insertBefore(list, last);
		else box.appendChild(list);
	}
	function createerror(msg, last){
		var list = document.createElement("tr");
		list.innerHTML = "<td colspan=\"8\">"+msg+"</td>";
		list.style.cssText = "color:red;";
		if(box.firstChild)box.insertBefore(list, last);
		else box.appendChild(list);
	}
	function Ctrl(ipt){
		if(timer>0){
			ipt.innerHTML = "启动";
			window.clearTimeout(timer);
			timer = 0;
		}else{
			var ml = document.getElementById("maxlines");
			if(!isNaN(ml.value)) max = parseInt(ml.value);
			ipt.innerHTML = "停止";
			start();
		}
	}
	function Clear(){
		while(box.lastChild) box.removeChild(box.lastChild);
	}
	window.onload = function(){
		box = document.getElementById("logs");
	};
	</script>
</head>
<body>
	<h2>ExceptionManager控制台</h2>
	<div id="panel">最大显示记录数：<input type="text" id="maxlines" value="50" /> [<a href="javascript:void(0)" onclick="Ctrl(this);">启动</a>] [<a href="javascript:void(0)" onclick="Clear();">清理</a>]</div>
	<table cellspacing="0" cellpadding="0" width="100%">
		<tr><th width="100">时间</th><th width="80">异常代码</th><th width="120">控制器/方法</th><th width="120">异常来源</th><th>信息</th><th width="30">级别</th><th>文件</th><th width="30">行号</th></tr>
		<tbody id="logs"></tbody>
	</table>
</body>
</html>